<html lang="en" >
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1">
	<style type="text/css">
      html,body{
        width: 100%;
        height: 100%;
        margin: 0px;
      }
      .map{
        touch-action:none;
        -ms-touch-action:none;
        height: 50%;
        width: 100%;

      }
      .bt{
        margin: 10px;
        border: groove 1px blue;
      }
      .log{
        font-size: 10px;
        margin: 0;
        width: 100%;
      }
    </style>
	<title>sdk辅助定位</title>
	<script type="text/javascript" src = 'https://webapi.amap.com/maps?v=1.4.4&test=true&key=8e9d3050695ac868cc67257d84a5f740&plugin=AMap.ToolBar,AMap.IndoorMap'></script>
</head>
<body >
<div id="container" class="map" tabindex="0"></div>

<button class = 'bt' onclick='geo.getCurrentPosition()'>获取位置</button>
<button class = 'bt' onclick='geo.watchPosition()'>连续定位</button>
<button class = 'bt' onclick='geo.clearWatch()'>停止定位</button>
<button class = 'bt' onclick='log.innerHTML = ""'>清除日志</button>
<div class = 'log'></div>

<script type="text/javascript">
      var log = document.getElementsByClassName('log')[0];
      var map = new AMap.Map('container',{
        resizeEnable: true,
        zoom: 10,
        center: [116.43, 39.9]
      });
      AMap.plugin(['AMap.Geolocation'],
      function(){
        geo  = new AMap.Geolocation({
          useNative:true
        })
        geo.on('complete',function(e){
          log.innerHTML+=e.info+' '+e.position+' '+e.message.split('.')[0]+'</br>'
        })
        geo.on('fail',function(e){
         log.innerHTML+=e.info+e.message.split('.')[0]+'</br>'
        })
      // map.addControl(geo);

    });
    </script>
</body>

</html>